<template>
  <div class="container">
    <el-dialog
      v-model="dialogVisible"
      title="维修设备"
      width="1200px"
      @closed="close"
      @open="openfn"
    >
      <div class="basepadding">
        <div class="basepadding" style="background: rgba(255, 255, 255, 0.1)">
          <z-from
            ref="searchfrom"
            :inline="true"
            label-position="left"
            label-width="100px"
            :nowinputs="Aftersearchinputs"
            size="small"
          >
            <template #zfromafter>
              <el-form-item style="margin: 0">
                <el-button type="primary" @click="searchfn()">搜索</el-button>
                <el-button @click="deletesearchfn()">清空</el-button>
              </el-form-item>
            </template>
          </z-from>
        </div>
      </div>

      <div class="basepadding">
        <z-table
          ref="tablez"
          v-loading="tableloading"
          :datas="After"
          :delsbtn="false"
          :tablecolumn="tablecolumn"
          @delfn="delfn"
        >
          <template #setting>
            <!--                        <el-table-column-->
            <!--                                align="center"-->
            <!--                                :label="setting.itemdata.label"-->
            <!--                                :prop="setting.itemdata.value"-->
            <!--                        >-->
            <!--                            <template #default="scope">-->
            <!--                                <el-button-->
            <!--                                        size="small"-->
            <!--                                        type="primary"-->
            <!--                                        @click="afterListedtfn(scope.row)"-->
            <!--                                >-->
            <!--                                    查看详情-->
            <!--                                </el-button>-->
            <!--                            </template>-->
            <!--                        </el-table-column>-->
          </template>
        </z-table>
      </div>
    </el-dialog>
  </div>
</template>
<script>
  import { Aftersearchinputs, tablecolumn } from '@/json/After.js'
  import zFrom from '@/components/zFrom/zFrom'
  import zTable from '@/components/zTable/index'

  export default {
    name: 'After',
    components: {
      zFrom,
      zTable,
    },
    data() {
      return {
        dialogfalg: false,
        dialogVisible: false,
        nowdata: {},
        nowinputs: {},
        dialogtitle: '',
        After: [],
        updatas: [],
        tablecolumn,
        tableloading: false,
        Aftersearchinputs,
        page: 'page',
        USearch22: [],
      }
    },
    mounted() {
      // this.AfterListfn()
    },
    methods: {
      async AfterListXJpdgtelfn() {
        let gtels = await this.$refs.tablez.handleSelects.map((e) => {
          return e.gtel
        })
        this.$refs.afterlistxjpd.show(gtels, () => {
          this.AfterListfn()
        })
      },
      show(data) {
        this.dialogVisible = true
        this.updatas = data.AfterList
        this.After = data.AfterList
        this.tablecolumn = tablecolumn.filter(function (e) {
          return e.type != 'selection' && e.value != 'setting'
        })
        this.Aftersearchinputs = Aftersearchinputs
      },
      async AfterListfn() {
        this.page = 'page'
        this.tableloading = true
        let data = await this.$z.$axios.post('/AfterList')
        this.updatas = data.data
        this.After = data.data
        this.tablecolumn = tablecolumn
        this.Aftersearchinputs = Aftersearchinputs
        this.tableloading = false
      },

      searchfn() {
        this.$refs.searchfrom.validate().then((updata) => {
          this.After = this.updatas.filter((e) => {
            for (let i = 0; i < this.Aftersearchinputs.length; i++) {
              let dqinput = this.Aftersearchinputs[i],
                v =
                  e[dqinput.value] || e[dqinput.value] == 0
                    ? e[dqinput.value]
                    : ''
              if (dqinput.type == 'select') {
                if (
                  updata[dqinput.value] &&
                  updata[dqinput.value] != '' &&
                  updata[dqinput.value] != v
                ) {
                  return false
                }
              } else {
                if (
                  updata[dqinput.value] &&
                  updata[dqinput.value] != '' &&
                  v.indexOf(updata[dqinput.value]) < 0
                ) {
                  return false
                }
              }
            }
            return true
          })
        })
      },
      deletesearchfn() {
        this.searchdata = {}
        this.$refs.searchfrom.settingfn()
        this.After = this.$z.deepClone(this.updatas)
      },

      openfn() {},
      closedfn() {},
    },
  }
</script>
<style lang="scss" scoped>
  @import '@/styles/tablecss.scss';
</style>
